package com.btpj.module_main.ui.tree

import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.btpj.jetpack.base.BaseFragment
import com.btpj.module_main.R
import com.btpj.module_main.adapter.TreeListAdapter
import com.btpj.module_main.databinding.FragmentTreeBinding
import kotlinx.android.synthetic.main.fragment_tree.*

/**
 * 体系
 *
 * @author LTP 2020/7/20
 */
class TreeFragment : BaseFragment<TreeViewModel, FragmentTreeBinding>() {

    private val mAdapter by lazy { TreeListAdapter() }

    companion object {

        @JvmStatic
        fun newInstance() = TreeFragment()
    }

    override fun getLayoutId() = R.layout.fragment_tree

    override fun initView() {
        recyclerView.apply {
            layoutManager = LinearLayoutManager(requireContext())
            adapter = mAdapter
        }
    }

    override fun createObserve() {
        super.createObserve()
        mViewModel.treeDataLiveData.observe(viewLifecycleOwner, Observer {
            mAdapter.setList(it)
        })
    }
}